MIUI security components.apk(点击下载) / j0.java


package com.tencent.turingfd.sdk.vd;

import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Process;
import android.text.TextUtils;
import android.util.Base64;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.regex.Pattern;

public class j0 {

    /* renamed from: a  reason: collision with root package name */
    public static final String f646a = i1.a(i1.f644b);

    /* renamed from: b  reason: collision with root package name */
    public static final String f647b = i1.a(i1.c);
    public static final String c = i1.a(i1.d);
    public static final String d = i1.a(i1.e);
    public static final String e = i1.a(i1.f);
    public static long f = 0;
    public static final String[] g = {"^/data/user/\\d+$", "^/data/data$"};

    /* access modifiers changed from: package-private */
    public static class a {

        /* renamed from: a  reason: collision with root package name */
        public final boolean f648a;

        /* renamed from: b  reason: collision with root package name */
        public final String f649b;

        public a(boolean z, String str) {
            this.f648a = z;
            this.f649b = str;
        }
    }

    public static String a() {
        StringBuilder a2 = d0.a("");
        a2.append(f);
        return a2.toString();
    }

    /* JADX INFO: finally extract failed */
    /* JADX WARNING: Code restructure failed: missing block: B:80:0x019e, code lost:
        r13 = null;
     */
    /* JADX WARNING: Removed duplicated region for block: B:104:0x0205  */
    /* JADX WARNING: Removed duplicated region for block: B:105:0x0210  */
    /* JADX WARNING: Removed duplicated region for block: B:108:0x0220  */
    /* JADX WARNING: Removed duplicated region for block: B:111:0x0247  */
    /* JADX WARNING: Removed duplicated region for block: B:112:0x024f  */
    /* JADX WARNING: Removed duplicated region for block: B:174:0x0343  */
    /* JADX WARNING: Removed duplicated region for block: B:176:0x0366  */
    /* JADX WARNING: Removed duplicated region for block: B:180:0x039a A[LOOP:2: B:178:0x0394->B:180:0x039a, LOOP_END] */
    /* JADX WARNING: Removed duplicated region for block: B:96:0x01d7  */
    public static String a(Context context) {
        a aVar;
        int i;
        boolean z;
        a aVar2;
        a aVar3;
        int a2;
        Iterator it;
        boolean z2;
        boolean z3;
        boolean z4;
        String str;
        String str2;
        String str3;
        Method method;
        String str4;
        String packageName;
        boolean z5;
        int indexOf;
        String substring;
        BufferedReader bufferedReader;
        FileReader fileReader;
        Throwable th;
        String str5;
        boolean z6;
        StringBuilder sb = new StringBuilder();
        long currentTimeMillis = System.currentTimeMillis();
        ArrayList arrayList = new ArrayList();
        File parentFile = context.getApplicationContext().getFilesDir().getParentFile();
        if (parentFile == null) {
            aVar = new a(false, "");
        } else {
            File parentFile2 = parentFile.getParentFile();
            if (parentFile2 == null) {
                aVar = new a(false, "");
            } else {
                String[] strArr = g;
                int length = strArr.length;
                int i2 = 0;
                while (true) {
                    if (i2 >= length) {
                        z6 = true;
                        break;
                    } else if (Pattern.compile(strArr[i2]).matcher(parentFile2.getAbsolutePath()).find()) {
                        z6 = false;
                        break;
                    } else {
                        i2++;
                    }
                }
                String absolutePath = parentFile.getAbsolutePath();
                String packageName2 = context.getPackageName();
                String[] split = absolutePath.split("/", 6);
                if (absolutePath.startsWith("/data/data/") && split.length >= 4 && !TextUtils.isEmpty(split[3])) {
                    packageName2 = split[3];
                } else if (absolutePath.startsWith("/data/user/") && split.length >= 5 && !TextUtils.isEmpty(split[4])) {
                    packageName2 = split[4];
                }
                aVar = (!z6 || packageName2.equals(context.getPackageName())) ? new a(z6, "") : new a(z6, a(context, packageName2));
            }
        }
        if (!aVar.f648a || TextUtils.isEmpty(aVar.f649b)) {
            z = false;
            i = f0.a(0, false, 0);
        } else {
            i = f0.a(0, true, 0);
            u uVar = new u();
            uVar.f687b = f646a + c;
            uVar.c = aVar.f649b;
            arrayList.add(uVar);
            z = false;
        }
        Context applicationContext = context.getApplicationContext();
        if (applicationContext == null) {
            aVar2 = new a(z, "");
        } else {
            int i3 = -1;
            try {
                fileReader = new FileReader("/proc/self/maps");
                try {
                    bufferedReader = new BufferedReader(fileReader);
                    while (true) {
                        try {
                            String readLine = bufferedReader.readLine();
                            if (readLine == null) {
                                break;
                            }
                            int indexOf2 = readLine.indexOf(47);
                            if (indexOf2 != i3) {
                                String trim = readLine.substring(indexOf2).trim();
                                if (Build.VERSION.SDK_INT >= 23) {
                                    if (trim.startsWith("/data/app/") && trim.endsWith("/base.odex")) {
                                        String[] split2 = trim.split("/");
                                        if (split2.length >= 7) {
                                            str5 = split2[3];
                                            break;
                                        }
                                    }
                                } else if (trim.startsWith("/data/dalvik-cache/") && trim.endsWith(".apk@classes.dex")) {
                                    int lastIndexOf = trim.lastIndexOf(47);
                                    if (lastIndexOf == -1) {
                                        i3 = -1;
                                    } else {
                                        String replace = trim.substring(lastIndexOf, trim.length() - 12).replace('@', '/');
                                        if (replace.startsWith("/data/app/")) {
                                            File file = new File(replace);
                                            if (!"base.apk".equals(file.getName())) {
                                                str5 = file.getName();
                                            } else if (file.getParentFile() != null) {
                                                str5 = file.getParentFile().getName();
                                            }
                                        }
                                    }
                                }
                                i3 = -1;
                            }
                        } catch (Throwable th2) {
                            th = th2;
                            try {
                                th.printStackTrace();
                                f0.a(fileReader);
                                f0.a(bufferedReader);
                                str4 = null;
                                packageName = applicationContext.getPackageName();
                                substring = str4.substring(0, indexOf);
                                if (!TextUtils.isEmpty(substring)) {
                                }
                                z5 = false;
                                if (z5) {
                                }
                                int a3 = f0.a(i, aVar2.f648a, 1);
                                if (aVar2.f648a) {
                                }
                                if (Build.VERSION.SDK_INT >= 17) {
                                }
                                a2 = f0.a(a3, aVar3.f648a, 2);
                                if (aVar3.f648a) {
                                }
                                if (a2 > 0) {
                                }
                                f = System.currentTimeMillis() - currentTimeMillis;
                                it = arrayList.iterator();
                                while (it.hasNext()) {
                                }
                                return sb.toString();
                            } catch (Throwable th3) {
                                f0.a(fileReader);
                                f0.a(bufferedReader);
                                throw th3;
                            }
                        }
                    }
                    str4 = str5;
                    f0.a(fileReader);
                    f0.a(bufferedReader);
                } catch (Throwable th4) {
                    th = th4;
                    bufferedReader = null;
                    th.printStackTrace();
                    f0.a(fileReader);
                    f0.a(bufferedReader);
                    str4 = null;
                    packageName = applicationContext.getPackageName();
                    substring = str4.substring(0, indexOf);
                    if (!TextUtils.isEmpty(substring)) {
                    }
                    z5 = false;
                    if (z5) {
                    }
                    int a32 = f0.a(i, aVar2.f648a, 1);
                    if (aVar2.f648a) {
                    }
                    if (Build.VERSION.SDK_INT >= 17) {
                    }
                    a2 = f0.a(a32, aVar3.f648a, 2);
                    if (aVar3.f648a) {
                    }
                    if (a2 > 0) {
                    }
                    f = System.currentTimeMillis() - currentTimeMillis;
                    it = arrayList.iterator();
                    while (it.hasNext()) {
                    }
                    return sb.toString();
                }
            } catch (Throwable th5) {
                th = th5;
                fileReader = null;
                bufferedReader = null;
                th.printStackTrace();
                f0.a(fileReader);
                f0.a(bufferedReader);
                str4 = null;
                packageName = applicationContext.getPackageName();
                substring = str4.substring(0, indexOf);
                if (!TextUtils.isEmpty(substring)) {
                }
                z5 = false;
                if (z5) {
                }
                int a322 = f0.a(i, aVar2.f648a, 1);
                if (aVar2.f648a) {
                }
                if (Build.VERSION.SDK_INT >= 17) {
                }
                a2 = f0.a(a322, aVar3.f648a, 2);
                if (aVar3.f648a) {
                }
                if (a2 > 0) {
                }
                f = System.currentTimeMillis() - currentTimeMillis;
                it = arrayList.iterator();
                while (it.hasNext()) {
                }
                return sb.toString();
            }
            packageName = applicationContext.getPackageName();
            if (!TextUtils.isEmpty(str4) && (indexOf = str4.indexOf("-")) != -1) {
                substring = str4.substring(0, indexOf);
                if (!TextUtils.isEmpty(substring)) {
                    File file2 = new File("/data/data/" + substring);
                    if (!file2.exists() || !file2.canWrite()) {
                        substring = packageName;
                    }
                    z5 = !TextUtils.equals(packageName, substring);
                    packageName = substring;
                    aVar2 = z5 ? new a(z5, a(context, packageName)) : new a(z5, "");
                }
            }
            z5 = false;
            if (z5) {
            }
        }
        int a3222 = f0.a(i, aVar2.f648a, 1);
        if (aVar2.f648a) {
            u uVar2 = new u();
            uVar2.f687b = f646a + d;
            uVar2.c = aVar2.f649b;
            arrayList.add(uVar2);
        }
        if (Build.VERSION.SDK_INT >= 17) {
            aVar3 = new a(false, "");
        } else {
            StringBuilder sb2 = new StringBuilder();
            if ("HUAWEI".equalsIgnoreCase(Build.BRAND)) {
                try {
                    Class<?> cls = Class.forName("android.os.UserManager");
                    Field field = context.getClass().getField("USER_SERVICE");
                    try {
                        field.setAccessible(true);
                        Object systemService = context.getSystemService((String) field.get(context));
                        if (!(systemService == null || (method = cls.getMethod("getUserName", new Class[0])) == null)) {
                            z2 = true;
                            try {
                                method.setAccessible(true);
                                str3 = (String) method.invoke(systemService, new Object[0]);
                            } catch (Throwable unused) {
                            }
                            z3 = false;
                            String str6 = new String(Base64.decode("5YiG6Lqr5bqU55So", 0));
                            if (!TextUtils.isEmpty(str3) && str6.equals(str3)) {
                                str = "HuaWei";
                            }
                            z2 = z3;
                            aVar3 = new a(z2, sb2.toString());
                        }
                    } catch (Throwable unused2) {
                        z2 = true;
                    }
                } catch (Throwable unused3) {
                }
                z2 = true;
                str3 = "";
                try {
                    z3 = false;
                } catch (Throwable unused4) {
                    z3 = false;
                    z4 = z3;
                    z2 = z4;
                    aVar3 = new a(z2, sb2.toString());
                    a2 = f0.a(a3222, aVar3.f648a, 2);
                    if (aVar3.f648a) {
                    }
                    if (a2 > 0) {
                    }
                    f = System.currentTimeMillis() - currentTimeMillis;
                    it = arrayList.iterator();
                    while (it.hasNext()) {
                    }
                    return sb.toString();
                }
                try {
                    String str62 = new String(Base64.decode("5YiG6Lqr5bqU55So", 0));
                    str = "HuaWei";
                } catch (Throwable unused5) {
                    z4 = z3;
                    z2 = z4;
                    aVar3 = new a(z2, sb2.toString());
                    a2 = f0.a(a3222, aVar3.f648a, 2);
                    if (aVar3.f648a) {
                    }
                    if (a2 > 0) {
                    }
                    f = System.currentTimeMillis() - currentTimeMillis;
                    it = arrayList.iterator();
                    while (it.hasNext()) {
                    }
                    return sb.toString();
                }
            } else {
                z2 = true;
                z3 = false;
                if ("xiaomi".equalsIgnoreCase(Build.BRAND)) {
                    if (b()) {
                        str2 = "XiaoMi";
                    }
                    z2 = z3;
                    aVar3 = new a(z2, sb2.toString());
                } else if ("oppo".equalsIgnoreCase(Build.BRAND)) {
                    if (b()) {
                        str2 = "OPPO";
                    }
                    z2 = z3;
                    aVar3 = new a(z2, sb2.toString());
                } else {
                    if ("vivo".equalsIgnoreCase(Build.BRAND)) {
                        if (b()) {
                            str2 = "VIVO_A";
                        } else {
                            if (new String(w0.a("/proc/self/mountinfo")).contains(context.getApplicationContext().getPackageName() + "_cloned")) {
                                str = "VIVO_B";
                            }
                        }
                    }
                    z2 = z3;
                    aVar3 = new a(z2, sb2.toString());
                }
                sb2.append(str2);
                aVar3 = new a(z2, sb2.toString());
            }
            try {
                sb2.append(str);
            } catch (Throwable unused6) {
                z4 = z2;
            }
            aVar3 = new a(z2, sb2.toString());
        }
        a2 = f0.a(a3222, aVar3.f648a, 2);
        if (aVar3.f648a) {
            u uVar3 = new u();
            uVar3.f687b = f646a + e;
            uVar3.c = aVar3.f649b;
            arrayList.add(uVar3);
        }
        if (a2 > 0) {
            u uVar4 = new u();
            uVar4.f687b = f646a + f647b;
            uVar4.c = d0.a("", a2);
            arrayList.add(uVar4);
        }
        f = System.currentTimeMillis() - currentTimeMillis;
        it = arrayList.iterator();
        while (it.hasNext()) {
            u uVar5 = (u) it.next();
            sb.append(uVar5.f687b);
            sb.append(":");
            sb.append(uVar5.c);
            sb.append(",");
        }
        return sb.toString();
    }

    public static String a(Context context, String str) {
        String str2;
        StringBuilder sb = new StringBuilder();
        sb.append(str);
        sb.append("_");
        try {
            str2 = context.getPackageManager().getApplicationInfo(str, 0).sourceDir;
        } catch (PackageManager.NameNotFoundException unused) {
            str2 = "";
        }
        try {
            sb.append(f0.a(new File(str2)).get(0));
        } catch (Throwable unused2) {
            sb.append("");
        }
        sb.append("_");
        long j = -1;
        if (!TextUtils.isEmpty(str2)) {
            File file = new File(str2);
            if (file.exists()) {
                j = file.length();
            }
        }
        sb.append(j);
        sb.append("_");
        sb.append(Process.myUid());
        return sb.toString();
    }

    public static boolean b() {
        try {
            return 999 == Process.myUid() / 100000;
        } catch (Throwable unused) {
            return false;
        }
    }
}